using Assets.Scripts.GDK;
using UnityEngine;

namespace Brick
{
	public class BallLineModule : gdk_base_Imodule
	{
		public static bool IsSegmentIntersectionWithSegment(ref Vector2 segment0Start, ref Vector2 segment0End, ref Vector2 segment1Start, ref Vector2 segment1End)
		{
			Vector2 b = segment0Start;
			Vector2 vector = segment0End - segment0Start;
			Vector2 a = segment1Start;
			Vector2 vector2 = segment1End - segment1Start;
			Vector2 vector3 = a - b;
			float num = vector.x * vector2.y - vector.y * vector2.x;
			float num2 = vector3.x * vector.y - vector3.y * vector.x;
			if (IsApproximately(num, 0.0))
			{
				if (IsApproximately(num2, 0.0))
				{
					return true;
				}
				return false;
			}
			float num3 = vector3.x * vector2.y - vector3.y * vector2.x;
			float num4 = num3 / num;
			float num5 = num2 / num;
			return num4 >= 0f && num4 <= 1f && num5 >= 0f && num5 <= 1f;
		}

		public static bool IsApproximately(double a, double b)
		{
			return IsApproximately(a, b, 0.0);
		}

		public static bool IsApproximately(double a, double b, double dvalue)
		{
			double num = a - b;
			return num >= 0.0 - dvalue && num <= dvalue;
		}
	}
}

